import requests
from lxml import etree
import time

for page in range(1, 101):
    url = f'https://book.zongheng.com/store/c0/c0/b0/u4/p{page}/v0/s9/t0/u0/i1/ALL.html'
    response = requests.get(url)
    html_str = response.content.decode()
    root = etree.HTML(html_str)
    story_list = root.xpath("//div[@class='bookinfo']")
    print(f"**********第{page}页开始**********")
    for story in story_list:
        author = story_type = " "
        book_name = "".join(story.xpath(".//div[@class='bookname']/a/text()"))
        target = story.xpath(".//div[@class='bookilnk']/a/text()")
        if len(target) == 2:
            author = target[0]
            story_type = target[1]
        profile = "".join(story.xpath(".//div[@class='bookintro']/text()"))
        story_link = "".join(story.xpath("../div[@class='bookimg']/a/@href"))
        print(f"书名:{book_name}\n作者:{author}\n类型:{story_type}\n简介:{profile}\n链接:{story_link}")
    print(f"__________第{page}页结束__________")
    time.sleep(2)
    break
